package controller

import (
	"github.com/crack007/go-im/src/common/constant"
	"github.com/crack007/go-im/src/module/api/dto"
	"github.com/crack007/go-im/src/module/api/service"
	"github.com/gin-gonic/gin"
)

type MessageController struct {
}

func (c *MessageController) Publish(ctx *gin.Context) interface{} {
	messageDto := dto.NewMessageDto()
	ctx.ShouldBindJSON(messageDto)
	messageDto.Action = constant.ACTION_CHAT
	return service.MessageService.Publish(messageDto, GetRequestUser(ctx))
}

func (c *MessageController) ListMessage(ctx *gin.Context) interface{} {
	queryDto := dto.NewMessageQueryDto()
	ctx.ShouldBindQuery(queryDto)
	return service.MessageService.ListMessage(queryDto)
}
